<html>
<head><meta charset="utf-8"><title>Resolve a path and retrieve `DefId` · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html">Resolve a path and retrieve `DefId`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233639425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233639425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233639425">(Apr 08 2021 at 11:53)</a>:</h4>
<p>I'm trying to create an attribute that accepts a <code>rustc_ast::Path</code>. I need to resolve it and retrieve a <code>LocalDefId</code>. Which function should i call?  I'm currently in <code>rustc_passes</code> crate but maybe it's best to do such resolution during lowering to hir, so maybe <code>rustc_ast_lowering</code> is better?</p>



<a name="233639559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233639559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233639559">(Apr 08 2021 at 11:54)</a>:</h4>
<p>maybe you're looking for <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#method.resolve_ast_path">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#method.resolve_ast_path</a> ?</p>



<a name="233639750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233639750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233639750">(Apr 08 2021 at 11:56)</a>:</h4>
<p>Thanks! It seems that function is private. Is there a public version?</p>



<a name="233639870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233639870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233639870">(Apr 08 2021 at 11:57)</a>:</h4>
<p>not sure, sorry</p>



<a name="233640413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233640413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233640413">(Apr 08 2021 at 12:01)</a>:</h4>
<p>it seems the only crate that has access to concrete types within resolve is <code>rustc_interface</code>...</p>



<a name="233641253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolve%20a%20path%20and%20retrieve%20%60DefId%60/near/233641253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolve.20a.20path.20and.20retrieve.20.60DefId.60.html#233641253">(Apr 08 2021 at 12:08)</a>:</h4>
<p>maybe i can try to see if i can expose a new function on <code>ResolverAstLowering</code>, and call the function above through it. Thanks a lot!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>